package com.simpleframe.views.ui;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.simpleframe.views.components.Component;
import com.simpleframe.views.components.FieldError;


public class FieldErrorTag extends ComponentTagSupport {
	
	private static final long serialVersionUID = 2074596370942301565L;

	protected String name;
	
	public Component getModelBean() {
		return new FieldError();
	}
	
	@Override
	protected void populateParameters() {
		super.populateParameters();
		FieldError fieldError = (FieldError)component;
		fieldError.setName(name);
		HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
		fieldError.setFieldErrors((Map<String, List<String>>) request.getAttribute("fieldErrors"));
		
	}

	public void setName(String name) {
		this.name = name;
	}
}
